// CIA model in the chapter 8 in the book of RBC of ABC
var w r c k h p g lambda;
varexo epslambda epsg;
parameters betax deltax theta A h0 gammax piex B barg;
betax = 0.99;
deltax = 0.025;
theta = 0.36;
A = 1.72;
h0 = 0.583;
gammax = 0.95;
piex = 0.48;
B = A*log(1-h0)/h0;
barg = 1;

model;
1/betax = w*(1-deltax+r(+1))/w(+1);
B/(w*p) = -betax/(p(+1)*c(+1)*g(+1));
p*c = 1;
k+1/p = w*h+r*k(-1)+(1-deltax)*k(-1);
w = (1-theta)*lambda*(k/h)^theta;
r = theta*lambda*(k/h)^(theta-1);
log(g) = (1-piex)*log(barg) + piex*log(g(-1))+epsg;
log(lambda) = gammax*log(lambda(-1)) + epslambda;
end;

[rss, wss, css, pss, kss, hss]=findss(betax,deltax,theta,barg,B);

initval;
r = rss;
w = wss;
c = css;
p = pss;
k = kss;
h = hss;
g = 1;
lambda = 1;
end;

steady;
resid;
check;

shocks;
var epslambda;
stderr 0.01;
%periods 1;
%values 0.01;
end;

%perfect_foresight_setup(periods = 100);
%perfect_foresight_solver;
stoch_simul(irf=100, order=1) k p w r h;